home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / esc.jar / com / extensibility / xa / ElementPane.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-06-30  |  7.9 KB  |  188 lines

  1. package com.extensibility.xa;
  2.  
  3. import com.extensibility.app.BaseAction;
  4. import com.extensibility.app.UI;
  5. import com.extensibility.rock.RAction;
  6. import com.extensibility.rock.RBevelBorder;
  7. import com.extensibility.util.RuleSplitPane;
  8. import com.extensibility.xml.BaseDeclaration;
  9. import com.extensibility.xml.ElementDeclaration;
  10. import java.awt.Container;
  11. import java.awt.Dimension;
  12. import java.awt.GridBagConstraints;
  13. import java.text.MessageFormat;
  14. import java.util.Enumeration;
  15. import java.util.Vector;
  16. import javax.swing.JComponent;
  17. import javax.swing.JLabel;
  18. import javax.swing.JList;
  19. import javax.swing.JPanel;
  20. import javax.swing.JScrollPane;
  21. import javax.swing.border.Border;
  22. import javax.swing.event.ListSelectionEvent;
  23. import javax.swing.event.ListSelectionListener;
  24.  
  25. public class ElementPane extends CompositePane implements ListSelectionListener {
  26.    RuleSplitPane horizontalSplit;
  27.    JScrollPane diagramScroller;
  28.    JScrollPane tableScroller;
  29.    ElementDiagram diagram = new 2(this, new ElementDiagramModel(((CompositePane)this).getSchemaDoc()));
  30.    ElementTable table;
  31.    JList list;
  32.    JScrollPane listScroll;
  33.    RuleSplitPane verticalSplit;
  34.    JLabel listLbl;
  35.    JPanel listPanel;
  36.    MessageFormat listMsgFormat;
  37.    ElementDeclaration diagramElem;
  38.    boolean autoUpdateDiagram = true;
  39.    BaseAction autoUpdateDiagramAction;
  40.  
  41.    public ElementPane(SchemaDoc var1) {
  42.       super(var1);
  43.       ViewportMatt var2 = new ViewportMatt(this);
  44.       ((JComponent)var2).setBackground(this.diagram.getBackground());
  45.       GridBagConstraints var3 = new GridBagConstraints();
  46.       var3.anchor = 10;
  47.       ((Container)var2).add(this.diagram, var3);
  48.       this.diagramScroller = new JScrollPane(var2);
  49.       this.diagramScroller.setBorder((Border)null);
  50.       this.diagramScroller.setPreferredSize(new Dimension(20, 20));
  51.       this.listMsgFormat = new MessageFormat(UI.getString("elem.used.by"));
  52.       this.listLbl = new JLabel(UI.getString("element.usedby.no.selection"));
  53.       this.listLbl.setBorder(new RBevelBorder());
  54.       this.list = new JList();
  55.       this.list.setBackground(UI.getColor(3));
  56.       this.list.addListSelectionListener(new 3(this));
  57.       this.listScroll = new JScrollPane(this.list);
  58.       this.listScroll.setBorder((Border)null);
  59.       this.listScroll.setColumnHeaderView(this.listLbl);
  60.       this.verticalSplit = new RuleSplitPane(1, this.diagramScroller, this.listScroll);
  61.       this.verticalSplit.setDividerRule(0.8);
  62.       this.table = new ElementTable(new ElementTableModel(((CompositePane)this).getSchemaDoc()));
  63.       if (!((CompositePane)this).getSchemaDoc().isSupported("GESTALT_EXTENDS")) {
  64.          this.table.hideColumn(3);
  65.       }
  66.  
  67.       this.table.addListSelectionListener(this);
  68.       this.tableScroller = new JScrollPane(this.table);
  69.       this.tableScroller.setBorder((Border)null);
  70.       this.tableScroller.setHorizontalScrollBarPolicy(30);
  71.       this.tableScroller.setVerticalScrollBarPolicy(22);
  72.       this.tableScroller.setCorner("UPPER_RIGHT_CORNER", this.table.createCorner());
  73.       this.horizontalSplit = new RuleSplitPane(0, this.verticalSplit, this.tableScroller);
  74.       this.horizontalSplit.setDividerRule(0.4);
  75.       this.horizontalSplit.setBorder((Border)null);
  76.       ((CompositePane)this).getSchemaDoc().addDocumentListener(new 4(this));
  77.    }
  78.  
  79.    public ElementDiagram getCurrentDiagram() {
  80.       return this.diagram;
  81.    }
  82.  
  83.    public BaseAction getZoomInAction() {
  84.       return this.diagram.getZoomInAction();
  85.    }
  86.  
  87.    public BaseAction getZoomOutAction() {
  88.       return this.diagram.getZoomOutAction();
  89.    }
  90.  
  91.    public JComponent getComponent() {
  92.       return this.horizontalSplit;
  93.    }
  94.  
  95.    public String getClassName() {
  96.       return "com.extensibility.xa.ElementPane";
  97.    }
  98.  
  99.    public boolean select(BaseDeclaration var1) {
  100.       return this.table.select(var1);
  101.    }
  102.  
  103.    public DeclTable getTableForClass(Class var1) {
  104.       return var1 == Class.forName("com.extensibility.xml.ElementDeclaration") ? this.table : null;
  105.    }
  106.  
  107.    public DeclTable getCurrentTable() {
  108.       return this.table;
  109.    }
  110.  
  111.    public boolean commitPendingEdits(boolean var1) {
  112.       return this.table.commitPendingEdits(var1);
  113.    }
  114.  
  115.    BaseAction getAutoUpdateDiagramAction() {
  116.       if (this.autoUpdateDiagramAction == null) {
  117.          this.autoUpdateDiagramAction = new 5(this, "view.item.auto.update");
  118.       }
  119.  
  120.       this.autoUpdateDiagramAction.setSelected(this.getAutoUpdate());
  121.       return this.autoUpdateDiagramAction;
  122.    }
  123.  
  124.    protected RAction createCutAction() {
  125.       return this.table.cutAction;
  126.    }
  127.  
  128.    protected RAction createCopyAction() {
  129.       return this.table.copyAction;
  130.    }
  131.  
  132.    protected RAction createPasteAction() {
  133.       return this.table.pasteAction;
  134.    }
  135.  
  136.    protected RAction createClearAction() {
  137.       return this.table.clearAction;
  138.    }
  139.  
  140.    protected RAction createExpandAction() {
  141.       return this.table.expandAction;
  142.    }
  143.  
  144.    protected void updateUsedByList(ElementDeclaration var1) {
  145.       Vector var2 = new Vector();
  146.       if (var1 != null) {
  147.          Enumeration var3 = ((CompositePane)this).getSchemaDoc().getUsedBy(var1);
  148.  
  149.          while(var3.hasMoreElements()) {
  150.             var2.addElement(((ElementDeclaration)var3.nextElement()).getName());
  151.          }
  152.       }
  153.  
  154.       this.list.setListData(var2);
  155.       this.listLbl.setText(this.listMsgFormat.format(new String[]{var1 == null ? "" : ((BaseDeclaration)var1).getName()}));
  156.       this.list.repaint();
  157.    }
  158.  
  159.    public void valueChanged(ListSelectionEvent var1) {
  160.       if (!var1.getValueIsAdjusting()) {
  161.          ElementDeclaration var2 = (ElementDeclaration)this.table.getSelectedDecl();
  162.          if (this.autoUpdateDiagram || ((CompositePane)this).getSchemaDoc().getSchema().indexOf(this.diagramElem) == -1) {
  163.             this.diagram.getModel().setRoot(var2);
  164.             this.updateUsedByList(var2);
  165.             this.diagramElem = var2;
  166.          }
  167.  
  168.          ((CompositePane)this).declarationFocused(var2);
  169.          this.verticalSplit.resetDividerLoc();
  170.       }
  171.    }
  172.  
  173.    public void setAutoUpdate(boolean var1) {
  174.       this.autoUpdateDiagram = var1;
  175.    }
  176.  
  177.    public boolean getAutoUpdate() {
  178.       return this.autoUpdateDiagram;
  179.    }
  180.  
  181.    public void focusDeclaration(BaseDeclaration var1) {
  182.       if (var1 instanceof ElementDeclaration && var1 != this.table.getSelectedDecl()) {
  183.          this.select(var1);
  184.       }
  185.  
  186.    }
  187. }
  188.